#include <am.h>
#include <riscv/riscv.h>

void __am_gpu_fbdraw(AM_GPU_FBDRAW_T *buf) {
  uint32_t base = 0x21000008;

  int x = buf->x;
  int y = buf->y;
  uint32_t *pixels = buf->pixels;
  int w = buf->w;
  int h = buf->h;

  if (pixels != NULL) {
    for (int j = 0; j < h; j ++) {
      for (int i = 0; i < w; i ++) {
        outl(base + (x + i) * 4 + (y + j) * 640 * 4, pixels[i+j*h]);
      }
    }
  }
}

